<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script th:src="@{/js/jquery.min.js}"></script>
    <style>
        body {
            width: 100%;
            height: 100%;
        }

        .div {
            text-align: center;
            margin: 0 auto;
            border: black solid 1px;
            width: 80%;
            height: 80%;
        }

        table {
            width: 100%;
            font-size: 15px;
        }

        tr {
            height: 40px;
        }

        div {
            text-align: center;
        }

        input[type="button"] {
            height: 15%;
            border: 2px solid #545454;
            border-radius: 5px;
            padding: 3px 6px;
            width: 20%;
            font-size: 20px;
            margin-bottom: 9px;

        }
    </style>
</head>
<body>
<div class="div">


    <h3 style="text-align: center">呼叫空托盘</h3>
    <hr>
    <div style="display: inline-block;margin: auto 0">
        <table>
            <tr class="tr">
                <td align="right"><div class="label">托盘类型：</div></td>
                <td align="left">
                    <select type="text" id="onLineType" name="onLineType" style="width: 170px;height: 25px;">-->
                        <option value="TPC">空托盘</option>
<!--                        <option value="LKC">1.6米托盘</option>-->
                    </select>
            </tr>
            <tr class="tr">
                <td align="right"><div class="label">出库口：</div></td>
                <td align="left">
                    <select style="width: 100%;height: 25px" id="ExitId" name="ExitId">
                        <option value="1">1号出口</option>
                        <option value="2">2号出口</option>
                        <option value="5">3号出口</option>
                    </select>
                </td>
            </tr>
        </table>
    </div>
    <div style="margin-top: 10px">
        <input type="button" id="submitbut" value="提交" onclick="saveOutJob()">
    </div>

</div>

</body>
<script>
    function saveOutJob() {
        var ExitId = document.getElementById("ExitId").value;
        var onLineType = document.getElementById("onLineType").value;

        if ((ExitId.length == "" || ExitId.length == null)) {
            alert("出口号不能为空！");
            return;
        }

        //控制按钮多次点击
        var btn = document.getElementById('submitbut');//首先需要获取的是哪一个按钮的id
        btn.disabled = 'disabled';//只要点击就将按钮的可点击的状态更改为不可以点击的状态
        setTimeout(function () {//设置时间，多久可以改变状态为可以点击
            btn.disabled = '';
        }, 5000);

        // $.post("/pda/trayOut", {
        //     onLineType :onLineType,
        //     ExitId : ExitId
        // }, function (result) {
        //     alert(result.v_resutmsg);
        //     window.location.reload();
        // }, "json");

        $.ajax({
            url: "/pda/trayOut",
            method: "POST",
            data: JSON.stringify({
                type :onLineType,
                exitId : ExitId
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                // 处理响应结果

                // 弹出处理成功的提示框
                alert(result.msg);

                // 清除输入框内容
                // $("#onLineType").val("");
                // $("#trayCode").val("");
                // $("#quantity").val("");
                // $("#entranceId").val("");
                // console.log(result);
            },
            error: function (xhr, status, error) {
                // 处理错误信息
                console.log(error);
                alert("生成出空托盘作业失败");
            }
        });
    }


</script>
</html>